/*
 *  RESTful DDS is a prototyping effort to demonstrate how DDS could be combined
 *  with HTTP clients, extending the realm of pub/sub distribution to true wide
 *  area networking.
 *
 *  Copyright (C) 2009 PrismTech Ltd.
 *  reinier.torenbeek@gmail.com
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License Version 3 dated 29 June 2007, as published by the
 *  Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with restful-dds; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

package org.opensplice.restful.service;

import org.restlet.Component;
import org.restlet.data.Protocol;

public class RESTfulDDSMain {
    public static void main(String[] args) {
        try {
            // Create a new Component.
            Component component = new Component();
    
            // Add a new HTTP server listening on port 8182.
            component.getServers().add(Protocol.HTTP, 8182);
            component.getClients().add(Protocol.FILE);  

            // Attach the DDS API
            component.getDefaultHost().attach("/dds",
                    new RESTfulDDSApplication());
            
            // Attach the static code, if required
          // Examples of a valid URI: "file:///C:/RESTfulDDS/www/" for
          //   windows, or "file:///home/RESTfulDDS/www" for Linux
            if(args.length < 1){
               System.out.println("No rootURI provided, " + 
                                  "no static pages available.");
            }
            else{
               String rootURI = args[0];
               System.out.println("Using rootURI " + rootURI);
               component.getDefaultHost().attach("/static",
                         new DemoApplication(rootURI));
            }
            
    
            // Start the component.
                component.start();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}
